<?php

class DegreesOfSeparationView extends View {

	protected $degree;
	protected $aList;
	
	function __construct() {
	
	}
	
	function getAList() {
		return $this->aList;
	}
	
	function setAList($a) {
		$this->aList = $a;
	}
	
	function getDegree() {
		return $this->degree;
	}
	
	function setDegree($d) {
		$this->degree = $d;
	}
	
	function display() {
		echo '<p>Choose two actors to calculate their distance</p>';
		echo '<form action="?page=degrees" method="POST">';
		echo '<table>';
		echo '<tr><td>'; $this->generateDirectorDropdown1(); echo '</td><td>'; $this->generateDirectorDropdown2(); echo '</td></tr>';
		echo '<tr><td><input type="hidden" name="action" value="action" /></td><td><input type="submit" value="Calculate Distance" class="btn btn-default" /></td></tr>';
		echo '</table>';
		echo '</form>';
		
		if (isset($this->degree)) {
			echo '<div><p>The degree of separation between the two actors is '.$this->degree.'.</p></div>';
		}
	}
	
	function generateDirectorDropdown1() {
		echo '<select name="actorID1">';
		foreach ($this->aList as $a) {
			echo '<option value="'.$a->getId().'">'.$a->getFirstName().' '.$a->getLastName().'</option>';
		}
		echo '</select>';
	}
	
	function generateDirectorDropdown2() {
		echo '<select name="actorID2">';
		foreach ($this->aList as $a) {
			echo '<option value="'.$a->getId().'">'.$a->getFirstName().' '.$a->getLastName().'</option>';
		}
		echo '</select>';
	}

}